//
//  ViewController.m
//  gongwei-ios
//
//  Created by gongwei-mac on 2020/1/20.
//  Copyright © 2020 gongwei-mac. All rights reserved.
//

#import "ViewController.h"
#import "service/websocket/GwWebsocket.h"
#import "service/common/ServiceRequest.h"
#import "service/serialize/Serializer.h"
#import "service/session/DefaultSessionContext.h"
#import "service/serialize/JsonSerializable.h"
@interface ViewController ()
@property (nonatomic,strong) GwWebsocket *socket;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.socket = [[GwWebsocket alloc] init];
    [self.socket SRWebSocketOpen];
    NSLog(@"<<<<<<<<<<<<<<<<<");
    DefaultSessionContext* sessionContext = [[DefaultSessionContext alloc] init];
    [sessionContext setSessionToken: @"sasadasdasdasdsdsa1111"];
    NSLog(@"%@", [sessionContext isKindOfClass:[JsonSerializable class]] ? @"yes" : @"no");
    
    NSLog(@"format is %@", [Serializer parseObjectToJsonString:sessionContext]);
    
    ServiceRequest *request = [[ServiceRequest alloc] init];

    NSMutableArray *array = [NSMutableArray array];
    [array addObject: sessionContext];
    [request fillId];
    [request setServiceName: @"com.gong_wei.service.api.cowork.GenericCoworkService"];
    [request setMethodName: @"getHighlights"];

    [request setParameterValues:array];
    NSLog(@"format is %@", [Serializer parseObjectToJsonString:request]);
    
    [NSThread sleepForTimeInterval:10.0f];
    NSLog(@"send ......................................");
    [self.socket sendData:[Serializer parseObjectToData:request]];
    // NSLog(@"11111111111111111");
}


@end
